<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\portal\validate;

use app\admin\model\RouteModel;
use think\Validate;
//验证创建订单
class AddOrderValidate extends Validate
{
    protected $rule = [
        'goods_type' => 'require|number',
        'goods_id' => 'require|number',
        'quantity' => 'require|number|minNum',
        'contact' => 'require|length:7,20',
        'saomaType' => 'require',
        'shop_name' => 'require|number',
    ];
    protected $message = [
        'goods_type' => '请选择分类',
        'goods_id' => '请选择产品',
        'quantity' => '请输入购买数量',
        'contact' => '请填写联系方式,必须是7-20个字符',
        'saomaType' => '请选择支付类型',
        'shop_name' => '商家错误',
    ];


    // 自定义验证规则
    protected function minNum($value, $rule, $data)
    {
        if(intval($value) <=0){
            return '必须下单数量最少一个';
        }else{
            return true;
        }

    }


}